package com.twu.biblioteca;

import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * User: ruchita
 * Date: 21/9/13
 * Time: 6:45 PM
 * To change this template use File | Settings | File Templates.
 */
public class ValidateUser {

    public String status="true";
    public String checkUserExistance(String username) {
        UserDetails u = getUserDetails(username);
        if(u==null)   //if user does not exists
            status="false";
        return status;
    }

    public String getPassword(String username) {
        return getUserDetails(username).password;
    }

    public int  getPhoneNumber(String username) {
        return getUserDetails(username).phoneNumber;
    }

    public String getEmailID(String username) {
        return getUserDetails(username).emailID;
    }

    public String getName(String username) {
        return getUserDetails(username).Name;
    }
    private UserDetails getUserDetails(String username) throws NullPointerException{
        UsersSampleDatabase udb=new UsersSampleDatabase();
        HashMap<String,UserDetails> map=udb.infoMap;
        return map.get(username);
    }
}
